Skip to content

Css keywords - #775

Closed
AlexanderWhitestone wants to merge 1 commit into
robotframework:masterfrom
AlexanderWhitestone:css_keywords
Closed

AlexanderWhitestone wants to merge 1 commit into
robotframework:masterfrom
AlexanderWhitestone:css_keywords

Conversation

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor

This keyword was written in a fork (I didn't write it)

Issue #774

I wasn't sure if I should keep the comment about the author or not.
I kept it because it was in the original repo.

@aaltat aaltat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the comments and write tests. At least write write following tests:

  1. Write few test that verify happy path
  2. Test where property does not contain expected value
  3. Test where element does not contain the CSS property
  4. Test where css property is a number. Considering also RF providing the number in different types: 5 versus ${5}
  5. Test where CSS property contains multiple elements, like: https://www.w3schools.com/cssref/pr_border.asp

## ##
## Author: Olivier Verville ##
## Date: May 24th 2016 ##
######################################################################

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove lines 58 - 64.

######################################################################
def element_css_attribute_should_be(self, locator, prop, expected):
"""Verifies the element identified by `locator` has the expected
value for the targeted `prop`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc strings must follow pep256

return element.text
return None

def _check_element_css_value(self, locator, prop, expected):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this method is only used in the Element Css Attribute Should Be it might be better idea to move the code from here to the keyword.


element = self._element_find(locator, True, True)

value = element.value_of_css_property(prop)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following pep8 is required, specially on the line length.

element = self._element_find(locator, True, True)

value = element.value_of_css_property(prop)
if (value != expected):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parentheses are not needed.


value = element.value_of_css_property(prop)
if (value != expected):
raise AssertionError("Element locator '%s' css property '%s' had a "\

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValueError could be better error class.

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

I agree with all the requested changes. Thanks @aaltat for the review and the feedback.
I will make the recommended changes hopefully soon.

@aaltat

aaltat commented Mar 18, 2017

Copy link
Copy Markdown
Contributor

For the new keyword, the code change looks OK. But it is missing the tests, which is not OK.

Also it looks like you used a tool to fix pep8 related errors, which is good thing too. But one pull request should do only a one thing. Having multiple fixes/enhancement in a one pull request makes the review harder. You can leave it for now but could you remember in the future.

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

I agree, I'll keep that in mind.
I still plan on writing the tests but it will take a bit longer as I needed to get acquainted with the test guidelines and be able to run them.

@aaltat

aaltat commented Mar 19, 2017

Copy link
Copy Markdown
Contributor

It's​explained in here: https://github.com/robotframework/Selenium2Library/blob/master/CONTRIBUTING.md#code-contributions and in here: https://github.com/robotframework/Selenium2Library/blob/master/BUILD.rst#unit-and-acceptance-tests

If you are developing in Windows, it might be good idea rebase with master. There is commit in master which fixes the test server problems when running in Windows.

@aaltat

aaltat commented Mar 27, 2017

Copy link
Copy Markdown
Contributor

How is the test case writing going on?

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

I'm unstuck, but I haven't had time to work on them. Work, school, competitions, and consulting have had me fully booked.

@aaltat

aaltat commented May 17, 2017

Copy link
Copy Markdown
Contributor

How is the test case writing going on?

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

I haven't had time to work on them directly, but I have written some tests for other new keywords not yet pulled. So the learning part is done. I'm still planning on adding the tests, I just don't know when it will happen.

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

I discovered some limitations.
If you set a color to a named value, Selenium won't necessarily read it as-is from the style sheet. It may return the RGB value instead of the named value like 'darkblue.'
So I guess this is not going to work for colors for now.

@pekkaklarck

Copy link
Copy Markdown
Member

It could also be the browser transforming color names to RGB values. In that case the actual behavior could also depend on the browser.

@aaltat

aaltat commented May 24, 2017

Copy link
Copy Markdown
Contributor

Verifying CSS can be complicated and one can run into unexpected problems. But I think it's still a good keyword to have.

The next release is coming soonnish and it would be nice to get this in.

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

I'm about half done with the tests. If the color values are browser specific, then I think that will have to be handled by the user of the keyword. For now I won't test for colors values because it might require browser specific conditions and would be difficult to maintain.

@aaltat

aaltat commented May 24, 2017

Copy link
Copy Markdown
Contributor

Sounds good to me.

@aaltat

aaltat commented Jun 26, 2017

Copy link
Copy Markdown
Contributor

Have you found time to finish this PR?

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

Sorry for the delay. I just started a new job so I haven't been working on this.

@aaltat

aaltat commented Jul 7, 2017

Copy link
Copy Markdown
Contributor

No worries. Do you think that at some point you would have time to finish this PR?

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

Yes, I will have time at some point.

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

Do we still want this? I let this PR get really old and I want to know if i should try fixing it.

@aaltat

aaltat commented Sep 28, 2018

Copy link
Copy Markdown
Contributor

Welcome back after so long time.

The feature gets asked now and then in the community and therefore the keywords would be good addition to the library. And if I recall correctly, it was just missing few acceptance tests.

If you have time and will to fix the PR, I am happy to review and merge it. The history should be cleaned tough. We usually do not use merge commit's and history should be clean. Which means that your commits should be on top of the commit's that are already in the master.

@AlexanderWhitestone

Copy link
Copy Markdown
Contributor Author

Yea I messed up the history while trying to pull in the latest. I will work on it and do a proper rebase so the commits are on top.

@aaltat

aaltat commented Oct 3, 2018

Copy link
Copy Markdown
Contributor

No problems, take your time.

@aaltat

aaltat commented Apr 22, 2019

Copy link
Copy Markdown
Contributor

Are you still planning to work on the PR or can we close it?

@AlexanderWhitestone

AlexanderWhitestone commented May 2, 2019 •

Copy link
Copy Markdown
Contributor Author

We can close it. I haven't been using the library and I'm not long familiar with it unfortunately.

I fixed the history and pushed what I had incase it helps anyone coming in to work on this in the future.

@aaltat

aaltat commented May 2, 2019

Copy link
Copy Markdown
Contributor

I understand and now worries. Thanks for effort and if there is a need, it can be always found from the GitHub.

@aaltat aaltat closed this May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants